package com.ellwood.modules.system.convert;

import com.ellwood.dataMapper.system.entity.UserEntity;
import com.ellwood.modules.system.domain.VO.user.UserEditVO;
import com.ellwood.modules.system.domain.VO.user.UserQueryVo;
import com.ellwood.modules.system.domain.VO.user.UserSaveVo;
import com.ellwood.modules.system.domain.dto.UserPageQueryDto;
import com.ellwood.modules.system.domain.dto.UserQueryDto;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @ProjectName: Ellwood-framework-boot
 * @PackageName: com.ellwood.modules.system.convert
 * @ClassName: UserConvert
 * @Description: // 用户实体-vo-dto-bo转换
 * @Author: Ellwood
 * @CreateDate: 2024/7/22 - 下午2:11
 * @Version: V1.0.0
 */
@Mapper
public interface UserConvert {

    UserConvert INSTANCE = Mappers.getMapper(UserConvert.class);

    // vo转entity
    @Mapping(target = "isState", ignore = true)
    UserEntity convertSaveEntity(UserSaveVo userVo);

    @Mapping(target = "password", ignore = true)
    @Mapping(target = "isState", ignore = true)
    UserEntity convertEditEntity(UserEditVO userVo);

    // entity转dto
    UserQueryDto convertQueryDto(UserEntity userEntity);

    // list<entity>转list<Vo>
    List<UserQueryVo> convertQueryVoList(List<UserEntity> userEntityList);

    // list<entity>转list<dto>
    List<UserQueryDto> convertQueryDtoList(List<UserEntity> userEntityList);

    // list<entity>转list<dto>
    List<UserPageQueryDto> convertPageQueryDtoList(List<UserEntity> userList);
}
